package com.kfc.platform.transaction.dao.impl;

import java.math.BigDecimal;
import java.util.List;

import org.hibernate.Session;

import com.kfc.platform.framework.jpa.BaseDaoImpl;
import com.kfc.platform.transaction.dao.TradeHistoryDao;
import com.kfc.platform.transaction.domain.TradeHistory;

public class TradeHistoryDaoImpl extends BaseDaoImpl<TradeHistory> implements TradeHistoryDao {

	@Override
	public TradeHistory gettradehistory(int listnum, String type, String status) {
		// TODO Auto-generated method stub
		Session s = this.getSession();
		List<TradeHistory> ls = s.createQuery("from TradeHistory t where t.listnum="+listnum
				+" and t.type='"+type+"' and t.status=:status").setString("status", status).list();
		return ls.get(0);
	}

	@Override
	public void updateTrade(int id,BigDecimal amount, String status, String date) {
		// TODO Auto-generated method stub
		Session s = this.getSession();
		s.createQuery("update TradeHistory t set t.amount="+amount+",t.status='"+status+"',t.trade_date='"+
		date+"' where t.id="+id).executeUpdate();
	}
}
